package com.zy.SqlsessionUtils;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.apache.log4j.lf5.util.Resource;

import java.io.IOException;
import java.io.InputStream;

public class sqlSessionUtil
{
    private static SqlSessionFactory sqlSessionFactory;
    static
    {
        String s="SQLMapConfig.xml";
        try
        {
            InputStream resourceAsStream = Resources.getResourceAsStream(s);
            sqlSessionFactory = new SqlSessionFactoryBuilder().build(resourceAsStream);
        } catch (IOException e)
        {
            e.printStackTrace();
        }
    }
    public static SqlSession getSqlsession()
    {
        return sqlSessionFactory.openSession();
    }
}
